package loopdemo;

import java.util.Random;
import java.util.Scanner;

public class looptest1 {
    public static void main(String[] args) {
/*
    需求：程序自动生成一个1-100之间的随机数，使用程序实现猜出这个数据是多少？
     */

        Random r = new Random();
        Scanner sc = new Scanner(System.in);
        int number = r.nextInt(100) + 1;
        while (true) {
            System.out.println("输入你要猜的数字：");
            int guessnumber = sc.nextInt();
            if (guessnumber > number) {
                System.out.println("大了");
            } else if (guessnumber < number) {
                System.out.println("小了");
            } else {
                System.out.println("猜对了！");
                break;
            }
        }
    }

}
